//
//  SCTypeBtn.m
//  BOSS-SOOC
//
//  Created by apple on 16/8/24.
//  Copyright © 2016年 Gcx. All rights reserved.
//
#define Color1a97e9 [UIColor colorWithRed:26.0/255 green:151.0/255 blue:233.0/255 alpha:1.0f]
#define Color0b8ee5 [UIColor colorWithRed:11.0/255 green:142.0/255 blue:232.0/255 alpha:1.0f]


#import "SCTypeBtn.h"

@implementation SCTypeBtn

- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    
    
    
    [self setTitle:@"登陆" forState:UIControlStateNormal];
    self.titleLabel.textColor = [UIColor whiteColor];
    self.titleLabel.font = NormalFont(45);
    [self setBackgroundImage:[self imageWithColor:Color1a97e9] forState:UIControlStateNormal];
    
    [self setBackgroundImage:[self imageWithColor:Color0b8ee5] forState:UIControlStateHighlighted];
    [self setBackgroundImage:[self imageWithColor:COLOR(211, 211, 211, 1.0)] forState:UIControlStateSelected];
    
    
    self.layer.masksToBounds = YES;
    self.layer.cornerRadius = 3;
    
    
    
}

-(void)setIsCanUse:(BOOL )isCanUse{
    
    
    if (isCanUse == NO) {
        self.selected = YES;
        self.userInteractionEnabled = NO;
    }else{
        
        self.selected = NO;
        
        self.userInteractionEnabled = YES;
        
        
    }
    
    
    
    
}




- (UIImage *)imageWithColor:(UIColor *)color {
    CGRect rect = CGRectMake(0.0f, 0.0f, 1.0f, 1.0f);
    UIGraphicsBeginImageContext(rect.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    
    CGContextSetFillColorWithColor(context, [color CGColor]);
    CGContextFillRect(context, rect);
    
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    
    return image;
}





@end
